{template 'web/common/common'}
{template 'web/user/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<div class="panel panel-success">
    <div class="panel-heading">
        <h3 class="panel-title">
            用户管理
        </h3>
    </div>
    <div class="panel-body">
        <div class="ibox-content">
            <form action="{url 'site/entry/user',array('m'=>'kundian_farm','version_id'=>$_GPC['version_id'])}" id="searchform" method="post">
                <div class="row" style="padding: 0 15px;">
                    <div class="col-sm-3">
                        <input type="text" class="form-control" placeholder="微信昵称" name="nickname" value="{$nickname}">
                    </div>
                    <div class="col-sm-2">
                        <button type="submit" class="btn btn-default " style="margin-right:5px;">查询</button>
                    </div>
                </div>
            </form>
        </div>
        <form action="" method="post" class="form-horizontal form">
            <input type="hidden" name="token" value="{$_W['token']}">

            <div class="table-responsive panel-body">
                <table class="table-striped table-bordered table-hover dataTables-example table">
                    <thead class="navbar-inner">
                    <tr>
                        <th>用户UID</th>
                        <th>微信昵称</th>
                        <th>头像</th>
                        <th>积分</th>
                        <th>优惠券(张)</th>
                        <th>添加时间</th>
                        <th style="text-align:right;">操作</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $list $index $item}
                    <tr>
                        <td><div class="type-parent">{$item['uid']}</div></td>
                        <td><div class="type-parent">{$item['nickname']}</div></td>
                        <td><div class="type-parent"><img src="{php echo $item['avatarurl'];}" width="50" height="50"/></div></td>
                        <td><div class="type-parent"><a href="{url 'site/entry/user',array('m'=>'kundian_farm','op'=>'score_record','uid'=>$item['uid'],'version_id'=>$_GPC['version_id'])}">{$item['score']}</a></div></td>
                        <td><div class="type-parent"><a href="{url 'site/entry/user',array('m'=>'kundian_farm','op'=>'coupon_list','uid'=>$item['uid'],'version_id'=>$_GPC['version_id'])}">{$item['coupon_count']}</a></p></div></td>
                        <td><div class="type-parent"><?php echo date('Y-m-d H:i:s',$item['create_time']);?></div></td>
                        <td style="text-align:right;">
                            <a href="{url 'site/entry/user',array('m'=>'kundian_farm','op'=>'edit','id'=>$item['id'],'version_id'=>$_GPC['version_id'])}" class="btn btn-primary btn-xs edit"><i class="fa fa-edit"></i>修改</a>
                            <a class="btn btn-danger btn-xs delete" data-id="{$item['id']}"><i class="fa fa-edit"></i>删除</a>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
                <div style="text-align: right;">
                    {$pager}
                </div>
            </div>
        </form>


    </div>
</div>
<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){

            //删除
            $(".delete").click(function(){
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '确定删除吗?',
                    text: "确定删除吗?",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '删除',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'delete','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('操作成功!', '操作成功!', 'success');
                                    that.parent().parent().remove();
                                }else{
                                    swal('操作失败!', '操作失败!', 'error');
                                }
                            }
                        })
                    }
                })
            });
        })
    })
</script>